home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 805 < prev    next >
Encoding:
Text File  |  1996-08-06  |  2.1 KB  |  54 lines

  1. Path: chronicle.mti.sgi.com!austern
  2. From: "joe (j.) halpin" <jhalpin@bnr.ca>
  3. Newsgroups: comp.std.c++
  4. Subject: Using pointers after delete
  5. Date: 21 Mar 1996 11:08:42 PST
  6. Organization: Bell-Northern Research, Richardson, TX
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <4irkhs$8al@crchh327.rich.bnr.ca>
  9. NNTP-Posting-Host: isolde.mti.sgi.com
  10. X-Original-Date:  Thu, 21 Mar 1996 13:11:24 +0000 
  11. Content-Identifier:  Using pointer... 
  12. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  13.     iQBVAwUBMVGpm0y4NqrwXLNJAQGtpgIAgXYveU7qMkMyxwlfi0myt0w5NTDN9qFP
  14.     RL+AcDtiraLG5Gvnj6QZFofuVOyC4kdHyPTm158EIKiQuKiAvGA3YA==
  15.     =0mMj
  16. Originator: austern@isolde.mti.sgi.com
  17.  
  18. In 3.7.3.2.4 the January working paper says:
  19.  
  20. 4 A deallocation function can free the storage referenced by the pointer
  21.   given  as  its  argument and renders the pointer invalid.  The storage
  22.   can be made available for further allocation.  An invalid pointer con-
  23.   tains an unusable value:  it cannot even be used in an expression.
  24.  
  25. This sounds as though, in the following:
  26.  
  27. char *pc = new char[128];
  28. delete pc;
  29. pc = 0;
  30.  
  31. it makes the final assignment (an expression) invalid.
  32.  
  33. Am I misunderstanding something, or is it illegal to zero out pointers
  34. after they've been deallocated? I'm assuming that the intent was to
  35. disallow dereferencing of pointers that have been handed to
  36. delete. The wording seems to disallow the above as well.
  37.  
  38. In fact, it sounds like it also rules out things like 'if(pc == 0)
  39. ...' after the above fragment.
  40.  
  41. Joe
  42. -- 
  43. Joe Halpin                             jhalpin@nortel.com
  44. Nortel Wireless                        (214) 684-5657 
  45. Richardson, TX  75083-3871             <standard disclaimer applies>
  46. -------------------------------------------------------------------------------
  47. ---
  48. [ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
  49.                 newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  50.   comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  51.   Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  52.   Comments? mailto:std-c++-request@ncar.ucar.edu 
  53. ]
  54.